package org.jpropelleralt.utils.impl;

import java.util.Iterator;

/**
 * Wraps another {@link Iterator} to make it unmodifiable (cannot
 * call {@link #remove()}
 * @param <T>	The type of iterated data.
 */
public class UnmodifiableIterator<T> implements Iterator<T> {

	private final Iterator<T> delegate;

	/**
	 * Create an {@link UnmodifiableIterator}
	 * @param delegate		The delegate touse for actual iteration
	 */
	public UnmodifiableIterator(Iterator<T> delegate) {
		super();
		this.delegate = delegate;
	}

	@Override
	public boolean hasNext() {
		return delegate.hasNext();
	}

	@Override
	public T next() {
		return delegate.next();
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException("Cannot delete from UnmodifiableIterator");
	}

}
